package demo.test;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.net.*;
import java.applet.*;


public class DemoApplet extends Applet {
    DemoPane demoPane ;
    Image bgImage ;
	
    public void init() {
		this.setLayout( new BorderLayout() ) ;
		MediaTracker tracker = new MediaTracker(this);
		demoPane = new DemoPane() ;

		Image img = getImage(getCodeBase(), getParameter("BgImage"));
		tracker.addImage(img,0) ;
		demoPane.setBgImage(img) ;
		img = getImage(getCodeBase(), getParameter("FixedNose")) ;
        tracker.addImage(img,0) ;

        try {
            tracker.waitForID(0);
            } catch (InterruptedException e) {
            System.out.println(e) ;
        }
		DisplayUnit unit= new DisplayUnit(img,255,242,100,200) ;
		unit.setActivable(true) ;
        unit.setMovable(false);
		demoPane.addUnit(unit) ;

		String mtext = getParameter("MovableText");
        unit = new DisplayUnit(mtext,0,240,200,30) ;
		unit.setFont(new Font("Simli",Font.PLAIN,15) ) ;
		unit.setForeground(Color.red) ;
        unit.setActivable(true);
        unit.setMovable(true);
		demoPane.addUnit(unit) ;
		
        img = getImage(getCodeBase(), getParameter("MovableImage") ) ;
        tracker.addImage(img,0) ;

        unit= new DisplayUnit(img,310,240,32,43) ;
        unit.setActivable(true) ;
		demoPane.addUnit(unit) ;

        img = getImage(getCodeBase(), getParameter("DukeImage") ) ;
        tracker.addImage(img,0) ;

        unit= new DisplayUnit(img,"Enjoy Java,Enjoy JoyJava!",40,40,120,90) ;
        unit.setTextRelativePostion(0,0);
        Font f = new Font("Arial",Font.PLAIN, 10);
        unit.setFont(f);
        unit.setActivable(true) ;
        demoPane.addUnit(unit) ;
        
		img = getImage(getCodeBase(), getParameter("Title") ) ;
        tracker.addImage(img,0) ;

        unit= new DisplayUnit(img,"title image",150,90,220,60) ;
        unit.setTextRelativePostion(145,0);
		unit.setActivable(true) ;
		unit.setMovable(false) ;
		demoPane.addUnit(unit) ;
				
		try {
			tracker.waitForID(0);
		    } catch (InterruptedException e) {
			System.out.println(e) ;
		}
		demoPane.setSize(getSize().width,getSize().height) ;
		add(demoPane) ;	
    }		
}